<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
USE common\models\business\BusinessContract;

use backend\assets\FancyBoxAsset;
FancyBoxAsset::register($this);
/* @var $this yii\web\View */
/* @var $model common\models\business\BusinessContract */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '合同', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
            <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">

            <div class="adv-table editable-table ">

                <div class="business-contract-view">

                    <table id="w0" class="table table-striped table-bordered detail-view">
                        <tbody>
                        <tr>
                            <th>ID</th>
                            <td><?= $model->id ?></td>
                        </tr>
                        <tr>
                            <th>分类名称</th>
                            <td><?= $model->category?$model->category->title:'' ?></td>
                        </tr>
                        <tr>
                            <th>合同名称</th>
                            <td><?= $model->name ?></td>
                        </tr>
                        <tr>
                            <th>合同编号</th>
                            <td><?= $model->no ?></td>
                        </tr>
                        <tr>
                            <th>甲方</th>
                            <td><?= $model->partyA ?></td>
                        </tr>
                        <tr>
                            <th>乙方</th>
                            <td><?= $model->partyB ?></td>
                        </tr>

                        <?php if(BusinessContract::isShow('amount',$showpre)) { ?>
                        <tr>
                            <th>金额</th>
                            <td><?= $model->amount ?></td>
                        </tr>
                        <?php } ?>

                        <?php if(BusinessContract::isShow('advance_ratio',$showpre)) { ?>
                        <tr>
                            <th>预付比例</th>
                            <td><?= $model->advance_ratio ?></td>
                        </tr>
                        <?php } ?>

                        <?php if(BusinessContract::isShow('start_time',$showpre)) { ?>
                        <tr>
                            <th>生效时间</th>
                            <td><?= $model->start_time ?></td>
                        </tr>
                        <?php } ?>

                        <?php if(BusinessContract::isShow('end_time',$showpre)) { ?>
                        <tr>
                            <th>失效时间</th>
                            <td><?= $model->end_time ?></td>
                        </tr>
                        <?php } ?>

                        <?php if(BusinessContract::isShow('final_amount',$showpre)) { ?>
                        <tr>
                            <th>决算金额</th>
                            <td><?= $model->final_amount ?></td>
                        </tr>
                        <?php } ?>

                        <?php if(BusinessContract::isShow('final_num',$showpre)) { ?>
                        <tr>
                            <th>决算数量</th>
                            <td><?= $model->final_num ?></td>
                        </tr>
                        <?php } ?>
                        <tr>
                            <th>甲方附件</th>
                            <td>
                                <?php foreach (\common\components\Upload::checkGetUrl($model->afile,true,'afile') as $key => $row) { ?>
                                    <a class='fancybox' rel="group1" href='<?=$row?>'>.<img src="<?= $row ?>" width="280px;" alt="" style="margin-left:20px;"></a>
                                <?php } ?>
                            </td>
                        </tr>
                        </tbody>
                    </table>

                    <!--附加字段-->

                    <?php if($model->category) { ?>
                        <table id="w0" class="table table-striped table-bordered detail-view">
                            <tbody>

                            <?php foreach($model->addonField as $key => $row) { ?>
                                <tr><th><?php echo $row->comment ?></th><td><?=\common\models\business\BusinessContract::fieldValue($model->id,$row->id) ?></td></tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    <?php } ?>




                </div>
            </div>
        </div>
    </section>
</section>


<script>
    <?php $this->beginBlock('js_end') ?>
    //点击预览图片
    $('.fancybox').fancybox({
        'titlePosition' : 'over',
        'cyclic'        : true,
        'height':500
    });
    <?php $this->endBlock(); ?>
    <?php $this->registerJs($this->blocks['js_end'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>

</script>